package com.wuyaya.arch.app.controller;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.wuyaya.arch.bom.manage.WuObjectFactory;
import com.wuyaya.arch.bom.obj.WuObjectDefinition;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class WelcomeController {

        @RequestMapping("/")
        public String welcome() throws Exception { // 添加 throws Exception 处理 ObjectMapper 可能抛出的异常
            WuObjectFactory.getObjectDefinition("com.wuyaya.arch.bom.obj", "WuUser");
            Map<String, WuObjectDefinition> jsonResult =WuObjectFactory.getWuObjectFactoryMap();
            StringBuffer stringBuffer=new StringBuffer();
            jsonResult.forEach((key, value) -> {
                stringBuffer.append(key + ":" + value.toString());
            });
            return "Welcome to Wu-Bom!" + stringBuffer.toString(); // 返回 JSON 字符串
        }
}
